package donajurema;

import org.eclipse.jface.dialogs.IDialogConstants;
import org.eclipse.jface.dialogs.TitleAreaDialog;
import org.eclipse.swt.SWT;
import org.eclipse.swt.graphics.Point;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.layout.FormLayout;
import org.eclipse.swt.layout.FormData;
import org.eclipse.swt.layout.FormAttachment;
import org.eclipse.wb.swt.SWTResourceManager;

public class AboutBox extends TitleAreaDialog
{

	public String version = "";
	/**
	 * Create the dialog.
	 * @param parentShell
	 */
	public AboutBox(Shell parentShell)
	{
		super(parentShell);
	}

	/**
	 * Create contents of the dialog.
	 * @param parent
	 */
	@Override
	protected Control createDialogArea(Composite parent)
	{
		setMessage("Copyright: GNU GPL (Open Source)");
		setTitleImage(SWTResourceManager.getImage(AboutBox.class, "/resources/cart.png"));
		setTitle("Dona Jurema");
		Composite area = (Composite)super.createDialogArea(parent);
		Composite container = new Composite(area, SWT.NONE);
		container.setLayout(new FormLayout());
		container.setLayoutData(new GridData(GridData.FILL_BOTH));
		
		Label lblVersion = new Label(container, SWT.NONE);
		FormData fd_lblVersion = new FormData();
		fd_lblVersion.top = new FormAttachment(0, 10);
		fd_lblVersion.left = new FormAttachment(0, 10);
		fd_lblVersion.right = new FormAttachment(100, -147);
		lblVersion.setLayoutData(fd_lblVersion);
		lblVersion.setText("Version: ");
		lblVersion.setText(lblVersion.getText() + version );
		
		Label lblAuthorFelipeCavalcanti = new Label(container, SWT.NONE);
		FormData fd_lblAuthorFelipeCavalcanti = new FormData();
		fd_lblAuthorFelipeCavalcanti.left = new FormAttachment(0, 10);
		fd_lblAuthorFelipeCavalcanti.top = new FormAttachment(lblVersion, 6);
		lblAuthorFelipeCavalcanti.setLayoutData(fd_lblAuthorFelipeCavalcanti);
		lblAuthorFelipeCavalcanti.setText("Author: Felipe Cavalcanti");

		return area;
	}

	/**
	 * Create contents of the button bar.
	 * @param parent
	 */
	@Override
	protected void createButtonsForButtonBar(Composite parent)
	{
		createButton(parent, IDialogConstants.OK_ID, IDialogConstants.OK_LABEL, true);
	}

	/**
	 * Return the initial size of the dialog.
	 */
	@Override
	protected Point getInitialSize()
	{
		return new Point(450, 300);
	}
}
